package com.example.authority.service.impl;

import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.authority.mapper.HomeMapper;
import com.example.authority.mapper.UserMapper;
import com.example.authority.service.HomeService;
import com.example.authority.service.UserService;
import com.example.authority.utils.RedisUtils;
import com.example.commons.common.Constant;
import com.example.commons.entity.Home;
import com.example.commons.entity.User;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.io.Serializable;

/**
 * @program: authority-v3.0.7
 * @ClassName:UserServiceImpl
 * @description: 首页表 service实现类
 * @author:dyy
 * @Version 3.0
 **/

@Service
@Slf4j
public class HomeServiceImpl extends ServiceImpl<HomeMapper, Home> implements HomeService {
    @Override
    public boolean checkActiveExists(Long excludeId) {
        LambdaQueryWrapper<Home> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Home::getState, 1); // 1表示展示中状态
        if (excludeId != null) {
            queryWrapper.ne(Home::getId, excludeId);
        }
        return this.count(queryWrapper) > 0;
    }
}
